import { request } from "../../request/index.js";
//Page Object
Page({
  data: {
    swiperList: [],
    catesList: [],
    floorList: [],
    navigator_url: ""
  },
  //开始加载触发
  onLoad: function (options) {
    //发送异步请求获取轮播图数据
    // wx.request({
    //   url: 'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata',      
    //   success: (result)=>{
    //     //console.log(result);
    //     this.setData({         
    //       swiperList:result.data.message
    //     })
    //   }
    // });
    this.getSwiperList();
    this.getCateList();
    this.getFloorList();
  },

  //获取轮播图数据
  getSwiperList() {
    request({ url: "/home/swiperdata" })
      .then(result => {
        this.setData({
          swiperList: result
        })
      })
  },
  //获取导航栏数据
  getCateList() {
    request({ url: "/home/catitems" })
      .then(result => {
        this.setData({
          catesList: result
        })
      })
  },
  //获取楼层数据
  getFloorList() {
    request({ url: "/home/floordata" })
      .then(result => {
        this.setData({
          floorList: result
        })
      })
  },
  handleGeturl(e) {
    const { url } = e.currentTarget.dataset;
    const navigator_url = url.replace("?", "/index?")
    // console.log(navigator_url)
    this.setData({
      navigator_url
    })
  }
});